package com.jiawa.train.business.controller.admin;

import com.jiawa.train.common.resp.PageResult;
import com.jiawa.train.common.resp.Result;
import com.jiawa.train.business.req.TrainSeatQueryReq;
import com.jiawa.train.business.req.TrainSeatSaveReq;
import com.jiawa.train.business.service.TrainSeatService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/trainSeat")
@Slf4j
public class TrainSeatAdminController {

    @Resource
    private TrainSeatService trainSeatService;
    @PostMapping("/save")
    public Result save(@RequestBody @Valid TrainSeatSaveReq req) {
        trainSeatService.save(req);
        return Result.success();
    }
    @GetMapping("/page")
    public Result<PageResult> queryTrainSeatList(TrainSeatQueryReq  req) {
       PageResult pageResult = trainSeatService.queryTrainSeatList(req);
       return Result.success(pageResult);
    }
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Long id) {
        trainSeatService.delete(id);
        return Result.success();
    }
}

